package com.sshm.mix.jwt.jjwt.controller;

import com.sshm.mix.jwt.jjwt.service.JwtService1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class BootControl {
    @Autowired
    private JwtService1 jwtService1;

    @PostMapping(value = "/token")
    public String token() {
        String id = "id";
        String issuer = "admin";
        String subject = "sub";
        long ttlMillis = System.currentTimeMillis();
        return jwtService1.createJWT(id, issuer, subject, ttlMillis);
    }

    @PostMapping(value = "/deToken")
    public String deToken() {
        return jwtService1.parseJWT(token());
    }
}